<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../../css/mui.min.css">
		<link rel="stylesheet" href="../css/common.css">
		<link rel="stylesheet" href="../formal/css/body.css?1">
		<title>测试页面</title>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">扫描二维码</h1>
		</header>
		<div class="mui-content mui-content-padded">
		    <button type="button" class="mui-btn mui-btn-blue mui-btn-block" id="startCan">开始扫描</button>
		    <button type="button" class="mui-btn mui-btn-blue mui-btn-block" id="startCanOne">识别本地</button>
		    <div id="scanContainer" style="width:300px; height:300px; border:1px solid red; margin:0px auto;"></div>
		    <div id="info"></div>
		</div>
		<script src='http://libs.baidu.com/jquery/1.8.3/jquery.min.js'></script>
		<script src="../../../js/mui.min.js"></script>
		<script>
			mui.plusReady(function(){
				
				var subpage_style = {
				    top: '0px',
				    bottom: '0px',
				    backButtonAutoControl: "none",
				}
				
				var embed=plus.webview.create('./h5/index.html','embed',subpage_style);
				var ws = plus.webview.currentWebview();
				ws.append(embed);
				
				
				
				
				$("#startCan").bind('tap',function(){
				        // 扫描二维码
				        var barScan = new plus.barcode.Barcode("scanContainer");
				        barScan.onmarked = function(type,code,file){
				            var result = "type"+type+"<br/>code:"+code+"<br/>file:"+file;
				            $("#info").html(result);
				        };
				        //barScan.start(); 开始扫描
				        barScan.start({conserve:true,filename:"_doc/barcode/"});// 可以配置扫描后保存的路径        
				});
				// 如何识别本地的二维码
				    $("#startCanOne").bind('tap',function(){
				        plus.gallery.pick(function(){
				            plus.barcode.scan(Path,function(type,code,file){
				                var result = "type"+type+"<br/>code:"+code+"<br/>file:"+file;
				                $("#info").html(result);
				            },function(error){
				                plus.nativeUI.alert('无法识别图片');
				            });
				        },function(err){
				            plus.nativeUI.alert('Failed:'+err.message);
				        });
				    });
			});
		</script>
	</body>
</html>
